package com.petrooil.core.service;

import com.petrooil.core.dao.WorkflowRuleDao;
import com.petrooil.core.model.WorkflowRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

@Service("workflowRuleService")
public class WorkflowRuleService implements IWorkflowRuleService {

    @Autowired
    private WorkflowRuleDao workflowRuleDao;

    @Override
    public WorkflowRule create(WorkflowRule workflowRule) {
        return workflowRuleDao.create(workflowRule);
    }

    @Override
    public WorkflowRule get(Serializable id) {
        return workflowRuleDao.get(id);
    }

    @Override
    public WorkflowRule update(WorkflowRule workflowRule) {
        return workflowRuleDao.update(workflowRule);
    }

    @Override
    public void delete(WorkflowRule workflowRule) {
        workflowRuleDao.delete(workflowRule);
    }

    @Transactional(readOnly = true)
    @Override
    public List<WorkflowRule> findAll() {
        return workflowRuleDao.findAll();
    }

    @Override
    @Transactional(readOnly = true)
    public List<WorkflowRule> getRulesByDepartment(String department) {
        return workflowRuleDao.getRulesByDepartment(department);
    }

    @Override
    @Transactional(readOnly = true)
    public WorkflowRule getRuleByFormAndDep(String form, String department) {
        return workflowRuleDao.getRuleByFormAndDep(form, department);
    }
}
